﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Microsoft.Web.Mvc"%>
<asp:Content ID="indexHead" ContentPlaceHolderID="head" runat="server">
    <title>Giỏ Hàng</title>
</asp:Content>
<asp:Content ID="css_js" ContentPlaceHolderID="js_css" runat="server">
    <script type="text/javascript" src="/scripts/jquery-1.4.2.min.js"></script>
</asp:Content>
<asp:Content ID="indexContentLeft" ContentPlaceHolderID="left_content" runat="server">
     <div class="title"><span class="title_icon"><img src="/content/images/bullet1.gif" alt="" title="" /></span>Giỏ hàng các sách mua</div>
        <% if(ViewData["error"] != null){ %>
            <div style="clear:both;margin-left:180px;color:Red;" ><%= ViewData["error"] %></div>
        <% } %>
        <div class="feat_prod_box_details">
            <% string[][] books = (string[][])ViewData["books"]; %>
            <% if (books != null && books.Length > 0){ %>
            <form action="buy" id="up" method="post" enctype="multipart/form-data" >
            <table class="cart_table">
            	<tr class="cart_title">
            	    <td>Bỏ</td>
                	<td>Hình Ảnh</td>
                	<td>Tên Sách</td>
                    <td>Giá Bán</td>
                    <td>SL</td>
                    <td>Tổng Cộng</td>               
                </tr>
                <% foreach (string[] row in books){ %>
            	<tr>
            	    <td><input type="checkbox" name="book_<%= row[6] %>" /></td>
                	<td><a href="/book/detail?id=<%= row[6]%>" title="<div style='width:300px'>
					        <div style='float:left;margin-left:5px;'>
						         <center><img onerror=this.src='/content/images/no_image.jpg' width='98' height='140' src='<%= row[7]%>'></center>
					        </div>
					        <div style='float:left;margin-left:25px'>
					             <div class='tt_name'>
						              <%= row[1]%>
					             </div>
					             <div class='tt_detail'>
						              <b>Mã Sách : </b><%= row[0]%> <br/><br/>
						              <b>Tác Giả : </b><%= row[2]%> <br/><br/>
						              <b>Giá Bán : </b><%= Html.Encode(row[3])%> VNĐ<br/><br/>
						              <b>Giá Thuê : </b><%= Html.Encode(row[4])%> VNĐ<br/><br/>
						              <b>Ngày Cập Nhật : </b><%= Html.Encode(row[8])%><br/><br/>
					             </div>
					        </div>
					        <div style='clear:both;'></div>	
				            </div>"><img onerror=this.src='/content/images/no_image.jpg' src="<%= row[7]%>" width="23" height="35" alt="" title="" border="0" class="cart_thumb" /></a></td>
                	<td><%= row[1]%></td>
                    <td><%= Html.Encode(row[3])%> VNĐ <input type="hidden" value="<%= row[3] %>" name="price_<%= row[6] %>" /></td>
					<td><input type="text" id="quantity" name="sl_<%= row[6] %>" size="1" maxlength="3" value="<%= row[13] %>" onKeyPress="return numbersonly(this, event);"></td>
                    <td><%= row[14]%> VNĐ</td>               
                </tr>
                <% } %>          
               
                <tr>
                <td colspan="4" class="cart_total"><span class="red">Thành Tiền:</span></td>
                <td colspan="2"> <%= ViewData["total"] %> VNĐ</td>                
                </tr>                  
            
            </table>
            <a href="/" class="continue">Quay Về</a>
            <a href="javascript::null;" onclick="document.getElementById('up').submit();" class="continue" style="margin-left:120px;">Cập Nhật</a>
            <a href="javascript:;" onclick = "Redirect();" class="checkout">Thanh Toán &gt;</a>
            </form>
            <% }else{ %>
            <div align="center">Chưa có cuốn sách nào trong giỏ hàng !</div>
            <% } %>
            </div>
</asp:Content>

<asp:Content ID="indexContentRight" ContentPlaceHolderID="right_content" runat="server">
   <% Html.RenderAction("index","sidebar"); %>
   <script type="text/javascript">
             function Redirect() {
                if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp = new XMLHttpRequest();
                }
                else {// code for IE6, IE5
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }

                xmlhttp.onreadystatechange = function() {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                        if(xmlhttp.responseText == -1)
                            {
                                document.location.href = "/payment/Payment?type=1";
                            }
                        if(xmlhttp.responseText == -2)
                        {
                             document.location.href = "/account/logon"; 
                        }
                    }
                }
                xmlhttp.open("GET", "/payment/jsonCheckLogin", true); 
                xmlhttp.send();
            }
            </script>
</asp:Content>
